package com.web.exiaodao.business.repository;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.web.exiaodao.business.entity.ShopCar;


public interface ShopCarRepository extends
		PagingAndSortingRepository<ShopCar, Long>,
		JpaSpecificationExecutor<ShopCar> {

	public ShopCar findByIdAndStatusNot(Long id,Integer status);

	@Query(value = " SELECT COUNT(*) FROM tb_xa_shopcar car LEFT JOIN tb_xa_shop shop ON car.shop_id = shop.id WHERE shop.status = 2  AND user_id = ? ", nativeQuery = true)
	public Long findByUserId(Long userId);

	/**
	 * 查询该商品是否在购物车中
	 * @param shopId
	 * @param standardIds 类型样式
	 * @see ShopCar standardIds
	 * @param userId
	 * @param status
	 * @author duandazhi
	 * @date 2016/12/2 下午3:32
	 * @return
	 */
	public ShopCar findByShopIdAndStandardIdsAndUserIdAndStatusNot(Long shopId,String standardIds,Long userId,Integer status);
}
